<template>
  <div class="app-container">
    <el-row class="app-toolbar">
      <el-button type="primary" @click="createRow">新增</el-button>
      <!-- <el-button type="danger" @click="deleteBatch">批量删除</el-button> -->
    </el-row>
    <el-table v-loading="listLoading" :data="datas" :empty-text="empty_text" element-loading-text="Loading" border fit stripe highlight-current-row>
      <el-table-column type="selection" width="50"></el-table-column>
      <el-table-column label="序号" align="center" width="60">
        <template slot-scope="scope">
          {{ scope.$index + 1 }}
        </template>
      </el-table-column>
      <!-- <el-table-column prop="id" label="序号" align="center" width="180"></el-table-column> -->
      <el-table-column label="项目名称" align="center" width="240">
        <template slot-scope="scope">
          {{ scope.row.name }}
        </template>
      </el-table-column>
      <el-table-column label="访问地址">
        <template slot-scope="scope">
          {{ scope.row.url }}
        </template>
      </el-table-column>
      <el-table-column label="项目类型" align="center" width="180">
        <template slot-scope="scope">
          {{ scope.row.typename }}
        </template>
      </el-table-column>
      <el-table-column label="显示排序" align="center" width="120">
        <template slot-scope="scope">
          {{ scope.row.order_number }}
        </template>
      </el-table-column>
      <el-table-column label="是否显示" align="center" width="150">
        <template slot-scope="scope">
          <el-switch v-model="scope.row.status" active-text="是" inactive-text="否" active-value="1" inactive-value="0" @change="statusRow(scope.row)"></el-switch>
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="240">
        <template slot-scope="scope">
          <el-button type="primary" @click="updateRow(scope.row)" size="small">编辑</el-button>
          <el-button type="danger" @click="deleteRow(scope.row, scope.$index)" size="small">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      layout="total, sizes, prev, pager, next, jumper"
      :current-page="listPages.page"
      :page-sizes="listPages.sizes"
      :page-size="listPages.size"
      :total="listPages.total"
      @size-change="_page_size_change"
      @prev-click="_page_prev_click"
      @current-change="_page_current_change"
      @next-click="_page_next_click"
    ></el-pagination>

    <el-dialog :title="formDialog.title" :visible.sync="formDialog.visible" :width="formDialog.width" :center="formDialog.center">
      <el-form :model="formData" :rules="rule" ref="form">
        <el-form-item label="项目名称" :label-width="formLabelWidth" prop="name"><el-input v-model="formData.name" style="width: 90%"></el-input></el-form-item>
        <el-form-item label="访问地址" :label-width="formLabelWidth" prop="url"><el-input v-model="formData.url" style="width: 90%"></el-input></el-form-item>
        <el-form-item label="项目类型" :label-width="formLabelWidth" prop="type">
          <el-select v-model="formData.type" placeholder="选择项目类型">
            <template v-for="data in projectTypeList">
              <el-option :label="data.name" :value="data.id"></el-option>
            </template>
          </el-select>
        </el-form-item>
        <el-form-item label="显示排序" :label-width="formLabelWidth"><el-input v-model="formData.order_number" style="width: 90%" onkeyup="this.value=this.value.replace(/\D/g,'')"></el-input></el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="formDialog.visible = false">取 消</el-button>
        <el-button type="primary" @click="_formDialogConfirm">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script></script>
<script src="./index.js"></script>
<style lang="scss" src="./index.scss"></style>
<style lang="scss" scoped src="./index.scoped.scss"></style>
